导航菜单
首页 >  PHP Image Validation  > How To Upload And Validate An Image File In PHP

How To Upload And Validate An Image File In PHP

In this tutorial, I will explain how to upload an image and how to validate image extension

 Create an HTML form with two text field :

One is for Image title with input type text.The second one is for upload image with input type file. For file upload input must be a file(type=” file”). This input type shows the file select control.

file upload in phpImage Title:Upload Image : 

Create a database with the name imagesdata. Inside this database, we create a table with the name tblimages.

SQL Script for tblimages—

CREATE TABLE IF NOT EXISTS `tblimages` ( `id` int(11) NOT NULL, `ImagesTitle` varchar(120) DEFAULT NULL, `Image` varchar(150) DEFAULT NULL, `PostingDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;

Now create a database connection file(config.php)

PHP Script for getting posted  values,  image validation, move images into directory and  insertion data into database

相关推荐: